<template>
  <div class="markdown-editor">
    <h2>Markdown 编辑器与预览器</h2>
    <div class="editor">
      <textarea v-model="markdownText" placeholder="请输入 Markdown 文本" rows="10"></textarea>
    </div>
    <div class="preview">
      <h3>预览：</h3>
      <div v-html="htmlContent"></div>
    </div>
  </div>
</template>

<script>
import { marked } from 'marked';

export default {
  name: "MarkdownEditor",
  data() {
    return {
      markdownText: ""
    };
  },
  computed: {
    htmlContent() {
      return marked(this.markdownText);
    }
  }
};
</script>

<style scoped>
.markdown-editor {
  max-width: 800px;
  margin: 20px auto;
  padding: 10px;
}
.editor textarea {
  width: 100%;
  padding: 8px;
  box-sizing: border-box;
  font-family: monospace;
}
.preview {
  margin-top: 20px;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
}
</style> 